export const formatDateTime = (timestamp, format = 'YYYY-MM-DD HH:mm:ss') => {
    if (!timestamp) return ''
    const date = new Date(timestamp)

    const pad = (n) => n.toString().padStart(2, '0')

    const replacements = {
        YYYY: date.getFullYear(),
        MM: pad(date.getMonth() + 1),
        DD: pad(date.getDate()),
        HH: pad(date.getHours()),
        mm: pad(date.getMinutes()),
        ss: pad(date.getSeconds())
    }

    return format.replace(/YYYY|MM|DD|HH|mm|ss/g, match => replacements[match])
}